-
Notifications
You must be signed in to change notification settings - Fork 0
accept attachment name or url to get addon config #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accept attachment name or url to get addon config #20
Conversation
src/add-ons/heroku-applink.ts
Outdated
* @returns Org | ||
*/ | ||
export async function getConnection(name: string): Promise<Org> { | ||
export async function getAuthorization(name: string, attachmentNameOrUrl = "APPLINK"): Promise<Org> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the param name
become developer_name_or_id
? It looks like the auth endpoint may accept either, considering the requested change:
From POST to GET: GET /addons/${addon_uuid}/authorizations/${developer_name_or_id}
@@ -29,7 +29,7 @@ fastify.get('/accounts', async function (request, reply) { | |||
const applinkAddon = request.sdk.addons.applink; | |||
|
|||
logger.info(`Getting org '${orgName}' connection from Heroku Applink add-on...`); | |||
const anotherOrg = await applinkAddon.getConnection(orgName); | |||
const anotherOrg = await applinkAddon.getAuthorization(orgName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need to rethink the example a bit here given the change to use a developer name instead of org name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, agree. Best to be consistent.
7281237
to
ce169a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
Plus GET
per WI update.
@@ -29,7 +29,7 @@ fastify.get('/accounts', async function (request, reply) { | |||
const applinkAddon = request.sdk.addons.applink; | |||
|
|||
logger.info(`Getting org '${orgName}' connection from Heroku Applink add-on...`); | |||
const anotherOrg = await applinkAddon.getConnection(orgName); | |||
const anotherOrg = await applinkAddon.getAuthorization(orgName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, agree. Best to be consistent.
src/add-ons/heroku-applink.ts
Outdated
|
||
const HTTP_REQUEST = new HttpRequestUtil(); | ||
|
||
/** | ||
* Get stored Salesforce or Data Cloud org user credentials for given name or alias. | ||
* @param name or alias | ||
* @param attachmentNameOrUrl Either an attachment name (e.g. "APPLINK") or a full URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. "APPLINK"
-> e.g. "HEROKU_APPLINK"
? Or, since that's the default, e.g. "MYNAME"
, e.g. "IVORY"
? Should we say it defaults to "HEROKU_APPLINK"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this should be HEROKU_APPLINK since that's the default attachment iirc.
src/add-ons/heroku-applink.ts
Outdated
export async function getConnection(name: string): Promise<Org> { | ||
export async function getAuthorization( | ||
name: string, | ||
attachmentNameOrUrl = "APPLINK" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEROKU_APPLINK
?
@@ -0,0 +1,56 @@ | |||
/* | |||
* Copyright (c) 2024, salesforce.com, inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025
. Favor: update date everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I'll handle that in a separate pr to avoid noise.
src/add-ons/heroku-applink.ts
Outdated
export async function getAuthorization( | ||
name: string, | ||
attachmentNameOrUrl = "APPLINK" | ||
): Promise<Org> { | ||
if (!name) { | ||
throw Error(`Connection name not provided`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Developer name
.
src/add-ons/heroku-applink.ts
Outdated
import { | ||
resolveAddonConfigByAttachment, | ||
resolveAddonConfigByUrl, | ||
} from "~/utils/addon-config"; | ||
|
||
const HTTP_REQUEST = new HttpRequestUtil(); | ||
|
||
/** | ||
* Get stored Salesforce or Data Cloud org user credentials for given name or alias. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given developer name
.
src/add-ons/heroku-applink.ts
Outdated
export async function getAuthorization( | ||
name: string, | ||
attachmentNameOrUrl = "APPLINK" | ||
): Promise<Org> { | ||
if (!name) { | ||
throw Error(`Connection name not provided`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Developer name
.
src/utils/addon-config.ts
Outdated
// Look for corresponding token | ||
const token = process.env[`${prefix}_TOKEN`]; | ||
if (!token) { | ||
throw Error(`Heroku Applink config not found for API URL: ${url}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Token not found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong feelings here right now. I can change to reference the missing token config var explicitly.
cdb2ad6
to
6ae41dc
Compare
Description
This pr renames getConnection -> getAuthorization it to accept a url or attachment name to resolve addon config.
Some other small changes as per https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00002C13J3YAJ/view:
developer_name
instead oforg_name
Todo